﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Net;
using Newtonsoft.Json;
using System.Net.Http;
using System.Net.Http.Headers;
using Water.Model;
using WaterApp.Common;

namespace WaterApp.Business
{
    public partial class TagInitialize : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void lnksave_Click(object sender, EventArgs e)
        {
            string url = WebapiUrl.weburl() + "AddTagAndDevice";
            Water.Model.TagInitialize ti = new Water.Model.TagInitialize()
            {
                DeviceType = ddrsbtype.SelectedValue,
                DeviceNo = tbsbno.Text,
                TagNo = tbtagno.Text
            };

            var requestJson = JsonConvert.SerializeObject(ti);
            HttpContent httpContent = new StringContent(requestJson);

            httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            var httpClient = new HttpClient();
            var responseJson = httpClient.PostAsync(url, httpContent)
                .Result.Content.ReadAsStringAsync().Result;

        }
    }
}